const { createApp, ref, reactive } = Vue;
const app = createApp({
    setup() {
        const input = ref('')
        const form = reactive({
            name: '',
            region: '',
            date1: '',
            date2: '',
            delivery: false,
            type: [],
            resource: '',
            desc: '',
        })

        const onSubmit = () => {
            console.log('submit!')
        }

        //新闻日志
        const logsForm = reactive({
            Add: {
                news_browe_logs: [
                    {
                        News_Browse_Log_SerialNumber: '1234',
                        News_SerialNumber: '测试',
                        Browser_SerialNumber: '444',
                        Browse_Datetime: '测试',
                        Row_Status: '1',
                        Operation_ID: '12',
                        Operation_Datetime: '0424'
                    }
                ]

            }
        })

        //新闻大类
        const categoryForm = reactive({
            Add: {
                news_category: [
                    {
                        // News_Category_SerialNumber:'N000001',
                        News_Category: '市域动态',
                        // Parent_SerialNumber:'01',
                        Row_Status: '0',
                        Children: {
                            news: [{
                                // News_SerialNumber:'NS0000000000005',
                                News_Title: '标题2',
                                // News_Category_SerialNumber:'N000001',
                                News_Content: '内容',
                                News_Views_Count: '11',
                                News_Image_URL: 'dij.png',
                                News_Publish_Datetime: '04-24',
                                Creater_SerialNumber: '007',
                                Row_Status: '0',
                            }]
                        }
                    }
                ]

            }
        })
        //修改新闻大类
        const categoryModify = {
            Modify: {
                news_category: [
                    {

                        News_Category_SerialNumber: 'N000002',
                        News_Category: '市域动态',
                        Parent_SerialNumber: '02',
                        Row_Status: '2',
                        News_Category_SerialNumber_Original: 'N000002',
                        News_Category_Original: '时政要闻',
                        Parent_SerialNumber_Original: '01',
                        Row_Status_Original: '1',
                    }
                ]

            }
        }
        // 新闻列表
        const newsForm = {
            Add: {
                news: [
                    {
                        News_SerialNumber: '',
                        News_Title: '标题',
                        News_Category_SerialNumber: 'NC0000000000003',
                        News_Content: '内容',
                        News_Views_Count: '11',
                        News_Image_URL: 'dij.png',
                        News_Publish_Datetime: '04-24',
                        Creater_SerialNumber: '007',
                        Row_Status: '0',
                        Children: {
                            news_picture: [
                                {
                                    News_SerialNumber: '',
                                    News_Piciture_URL: 'dij.png',
                                    Picture_Order: '12',
                                    Create_Datetime: '04-24',
                                    Creater_SerialNumber: '007',
                                    Row_Status: '0'
                                }
                            ]
                        }
                    }
                ]
            }
        }
        // 修改新闻列表
        const newsModify = {
            Modify: {
                news: [
                    {
                        News_SerialNumber: 'NS20001',
                        News_Title: '标题',
                        News_Category_SerialNumber: 'N000002',
                        News_Content: '内容',
                        News_Image_URL: '图片路径',
                        News_Views_Count: '15',
                        News_Publish_Datetime: '0424',
                        Creater_SerialNumber: '77777',
                        Row_Status: '1',
                        News_SerialNumber_Original: 'NS20001',
                        News_Title_Original: '标题',
                        News_Category_SerialNumber_Original: 'N000002',
                        News_Content_Original: '内容',
                        News_Image_URL_Original: '图片路径',
                        News_Views_Count_Original: '',
                        News_Publish_Datetime_Original: '0424',
                        Creater_SerialNumber_Original: '77777',
                        Row_Status_Original: '1',
                    }
                ]

            }
        }

        //图片列表
        const picturesForm = {
            Add: {
                news_picture: [
                    {
                        News_Picture_SerialNumber: 'NS0001',
                        News_SerialNumber: 'NS0000000000006',
                        News_Piciture_URL: 'dij.png',
                        Picture_Order: '11',
                        Create_Datetime: '04-24',
                        Creater_SerialNumber: '007',
                        Row_Status: '1'
                    }
                ]
            }
        }

        const postNewsAdd = () => {
            // console.log(JSON.stringify(logsForm))
            $.ajax({
                headers: {
                    "content-type": "application/x-www-form-urlencoded",
                },
                url: "https://service.essp.top/apiForMoHe/generalBusiness/generalSave",
                method: "post",
                data: {
                    Data: JSON.stringify(categoryForm), //表名
                    //   Condition: '',
                },
                success: (res) => {
                    console.log('uuclk', res);
                },
                error: (err) => {
                    console.log(err);
                },
            });
        }

        return {
            input,
            form,
            onSubmit,
            logsForm,
            categoryForm,
            categoryModify,
            newsForm,
            newsModify,
            picturesForm,
            postNewsAdd
        }
    }
});


//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}

app.use(ElementPlus);
app.mount("#app");
